package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Clazz;
import cn.kgc.springcloud.service.ClazzService;
import cn.kgc.springcloud.vo.ClazzVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 课工场
 * @date 2025/1/17
 * @description
 */
@RestController
@RequestMapping("clazz")
public class ClazzController {

    @Resource
    private ClazzService clazzService;

    @GetMapping
    public List<ClazzVO> clazzList(){

        return  clazzService.clazzList();
    }


    //删除班级
    @DeleteMapping("{id}/{logo}")
    public boolean deleteById(@PathVariable("id") Integer id,@PathVariable("logo") String logo){

        return  clazzService.removeClazzById(id,logo);
    }

    // 添加班级信息
    @PostMapping
    public boolean addClazz(MultipartFile file,String name,Integer  tagId){
        return clazzService.addClazz(file,name,tagId);
    }


    @GetMapping("{id}")
    public Clazz getClazzById(@PathVariable("id") Integer id){
        return  clazzService.getById(id);
    }


}
